package com.myproject.music.service.impl;

import com.myproject.music.BizException;
import com.myproject.music.domain.Concert;
import com.myproject.music.mapper.ConcertMapper;
import com.myproject.music.service.ConcertService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConcertServiceImpl implements ConcertService {
    private static final Logger log = LoggerFactory.getLogger(ConcertServiceImpl.class);
    @Autowired
    private ConcertMapper concertMapper;

    @Override
    public List<Concert> selectConcertAll() {
        return concertMapper.selectConcertAll();
    }

    @Override
    public Concert selectConcertById(Long id) {
        Concert concert =concertMapper.selectConcertById(id);
        if(concert ==null){
            log.error("该演唱会"+id+"不存在");
            throw new BizException("该演唱会"+id+"不存在");
        }
        log.info("查询演唱会"+id+"成功");
        return concertMapper.selectConcertById(id);
    }

    @Override
    public List<Concert> selectConcertByParam(String concertName) {
        return concertMapper.selectConcertByParam(concertName);
    }

    @Override
    public int insertConcert(Concert concert) {
        return concertMapper.insertConcert(concert);
    }

    @Override
    public int updateConcert(Concert concert) { return concertMapper.updateConcert(concert);}

    @Override
    public int deleteConcertById(Long id) {
        return concertMapper.deleteConcertById(id);
    }
}
